export function levelOrderBottom(root: TreeNode | null): number[][] {
    if (!root) return []
    const res: number[][] = []
    const tempArr: TreeNode[] = [root]
    while (tempArr.length) {
        const len = tempArr.length;
        const temp: number[] = []
        for (let index = 0; index < len; index++) {
            const node = tempArr.shift()
            if (node.left) tempArr.push(node.left)
            if (node.right) tempArr.push(node.right)
            temp.push(node.val)
        }
        res.unshift(temp)
    }
    return res
};